package com.wing.wcabinet.model.entity;

import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.wing.mybatis.common.BaseEntity;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
 * 售刀柜领取/暂存柜上/暂存/维修/回收
 *
 * @author
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("wcab_use_inventory_inout")
public class WcabUseInventoryInout extends BaseEntity<WcabUseInventoryInout> implements Serializable {

    private static final long serialVersionUID = 1L;

    public enum InoutType implements IEnum<Integer> {

        /**
        * 暂存/维修/回收存入
        */
        in(1,"暂存/维修/回收存入"),
        /**
        * 领取
        */
        out(2,"领取");

        private int code;
        private String desc;

        InoutType(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
    }

    public enum BusinessType implements IEnum<Integer> {


        normal(1,"正常"),
        /**
         * 维修
         */
        repair(2,"维修"),
        /**
         * 报废
         */
        recycle(3,"报废");

        private int code;
        private String desc;

        BusinessType(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }

        @JsonCreator
        public static BusinessType jsonCreator(String name) {
            if (org.apache.commons.lang.StringUtils.isNotBlank(name)) {
                for (BusinessType item : values()) {
                    if (item.name().equals(name.trim())) {
                        return item;
                    }
                }
            }
            return null;
        }
    }

    public enum OperationType implements IEnum<Integer> {

        /**
        * 售刀柜领取
        */
        out(1,"售刀柜领新"),
        /**
         * 退货
         */
        returnedIn(5,"退货"),
        /**
         * 维修
         */
        repairIn(6,"维修存入"),
        /**
         * 报废
         */
        recycleIn(7,"报废存入");

        private int code;
        private String desc;

        OperationType(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
    }

    /**
     * 创建者
     */
    private Long creator;

    /**
     * 修改者
     */
    private Long modifier;

    /**
     * 创建人
     */
    private String creatorName;

    /**
     * 修改人
     */
    private String modifierName;

    /**
     * 存/取刀任务编号
     */
    private String code;

    /**
     * 售刀柜领取/暂存柜上/暂存/维修/回收业务id
     */
    private Long businessId;

    /**
     * 操作类型
     */
    private InoutType inoutType;

    /**
    * 操作类型描述
    */
    @TableField(exist = false)
    private String inoutTypeDesc;

    public String getInoutTypeDesc() {
        return inoutType == null ? null : inoutType.getDesc();
    }

    /**
     * no
     */
    private Integer no;

    /**
     * day
     */
    private Integer day;

    /**
     * 业务类型
     */
    private BusinessType businessType;

    /**
    * 业务类型描述
    */
    @TableField(exist = false)
    private String businessTypeDesc;

    public String getBusinessTypeDesc() {
        return businessType == null ? null : businessType.getDesc();
    }

    /**
     * 设备编号
     */
    private String deviceCode;

    /**
     * orderCode
     */
    private String orderCode;

    /**
     * cellInventoryInoutId
     */
    private Long cellInventoryInoutId;

    /**
     * 工序id
     */
    private Long processId;

    /**
     * 计划id
     */
    private Long planId;

    /**
     * enterpriseId
     */
    private Long enterpriseId;

    /**
     * enterpriseCode
     */
    private String enterpriseCode;

    private OperationType operationType;

    @TableField(exist = false)
    private String operationTypeDesc;

    public String getOperationTypeDesc(){
        if (operationType!=null){
            return operationType.getDesc();
        }
        return "";
    }

    public enum Type implements IEnum<Integer> {

        /**
         * 暂存/维修/回收存入
         */
        in(1,"领取"),
        /**
         * 领取
         */
        out(2,"暂存/暂存维修/暂存回收"),

        returned(3,"归还"),

        importByExcel(4,"在用导入"),

        inByCheck(5,"盘验维修/报废转暂存(虚拟转出)");

        private int code;
        private String desc;

        Type(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
    }


    private Type type;

    private String departmentName;

    private String roleName;

}
